/*
 * Copyright 2013 JROSE
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jrose.core.mongo.persistence;

import com.mongodb.DBObject;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import java.io.Serializable;
import java.util.List;

public interface MongoPersistence<T, ID extends Serializable> {
    T save(T entity);

    <S extends T> List<S> save(Iterable<S> entites);

    T findOne(ID id);

    boolean exists(ID id);

    List<T> findAll();

    List<T> findAll(DBObject fieldsObject);

    List<T> findAll(Sort sort);

    List<T> findAll(DBObject fieldsObject, Sort sort);

    Page<T> findAll(Pageable pageable);

    Page<T> findAll(DBObject fieldsObject, Pageable pageable);

    long count();

    long count(DBObject queryObject);

    void delete(ID id);

    void delete(T entity);

    void delete(Iterable<? extends T> entities);

    void deleteAll();

    void delete(DBObject queryObject);

    void dropCollection();

    T findOne(DBObject queryObject);

    T findOne(DBObject queryObject, DBObject fieldsObject);

    T findOne(DBObject queryObject, Sort sort);

    T findOne(DBObject queryObject, DBObject fieldsObject, Sort sort);

    List<T> find(DBObject queryObject);

    List<T> find(DBObject queryObject, DBObject fieldsObject);

    List<T> find(DBObject queryObject, Sort sort);

    List<T> find(DBObject queryObject, DBObject fieldsObject, Sort sort);

    List<T> find(DBObject queryObject, Sort sort, int limit);

    List<T> find(DBObject queryObject, DBObject fieldsObject, Sort sort, int limit);

    List<T> find(DBObject queryObject, Sort sort, int limit, int skip);

    List<T> find(DBObject queryObject, DBObject fieldsObject, Sort sort, int limit, int skip);

    Page<T> find(DBObject queryObject, Pageable pageable);

    Page<T> find(DBObject queryObject, DBObject fieldsObject, Pageable pageable);
}
